home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr31 / hades.zip / HITS.C < prev    next >
C/C++ Source or Header  |  1992-04-14  |  3KB  |  151 lines

  1.  
  2. /***************
  3. **
  4. **  hits.c
  5. **  last revised: april 12, 1992
  6. **
  7. **  hits generates a list of passwords that were cracked in earlier
  8. **  sessions of hades. It reads a passwordlist as generated by hades
  9. **  and scans the password-field for the '=' character. when found,
  10. **  the rest of the field is written to the dictionary.
  11. **
  12. **  Usage: hits [-f resultfile] [-o outfile]
  13. **
  14. **  Written for DESPERATE password-cracker with HADES encryption engine by
  15. **  Remote.
  16. **
  17. **  Copyright (C)1992, Zabkar
  18. **
  19. **  root@waves.hacktic.nl (Zabkar)
  20. **  root@room101.hacktic.nl (Remote)
  21. **
  22. */
  23.  
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include "pwd.h"
  27.  
  28.  
  29. FILE *outfile;
  30. FILE *infile;
  31.  
  32. extern FILE *_pw_file;     /* So sneaky, it could have been from CC! */
  33.                            /* I wonder if it works under UNIX!!      */
  34.  
  35.  
  36. /***************
  37.  haltusage()
  38.  prints correct usage and exits
  39. ****************/
  40.  
  41. void haltusage()
  42. {
  43.   fprintf(stderr,
  44.   "Hits version 1.00 alpha, Copyright (C)1992 Zabkar\n"\
  45.   "DESPERATE password-cracker 1.0 alpha using HADES engine by Remote.\n\n"\
  46.   "Usage: hits [-f resultfile] [-o outfile]\n\n"\
  47.   "\t-f: read from 'resultfile' instead of stdin\n"\
  48.   "\t-o: write to 'outfile' instead of stdout\n\n"\
  49.   "no -f specified: resultfile read from stdin\n"\
  50.   "no -o specified: output written to stdout\n");
  51.   exit(0);
  52. }
  53.  
  54.  
  55. /***************
  56.  createhitlist()
  57.  creates a list of the earlier cracked passwords that are stored in
  58.  the hades-resultfile inf and writes the list to file of.
  59. ***************/
  60.  
  61. void createhitlist(FILE *inf, FILE *of)
  62. {
  63.     char *word;
  64.     struct passwd *buf;
  65.  
  66.     _pw_file = inf;
  67.     while ((buf = getpwent()) != NULL)
  68.     {
  69.         word = strchr(buf->pw_passwd, '=');
  70.         if (strlen(word) > 1)       /* chars after the '='? */
  71.            fprintf(of, "%s\n", &word[1]);
  72.     }
  73. }
  74.  
  75.  
  76.  
  77. /***************
  78.  main()
  79.  main function of program hits
  80. ****************/
  81.  
  82. main(char argc, char **argv)
  83. {
  84.   char fname[80], oname[80];
  85.   int i;
  86.  
  87.   strcpy(fname, "");
  88.   strcpy(oname, "");
  89.  
  90.   if (argc > 1)
  91.   {
  92.     for (i=1; i<argc; i++)
  93.     {
  94.       switch(argv[i][0])
  95.       {
  96.       case '-': switch(toupper(argv[i][1]))
  97.           {
  98.             case 'F' : if (strlen(argv[i]) > 2)
  99.                  strcpy(fname, &argv[i][2]);
  100.                    else if (argc < (i+2))
  101.                  haltusage();
  102.                    else
  103.                  strcpy(fname, argv[++i]);
  104.                    break;
  105.             case 'O' : if (strlen(argv[i]) > 2)
  106.                  strcpy(oname, &argv[i][2]);
  107.                    else if (argc < (i+2))
  108.                  haltusage();
  109.                    else
  110.                  strcpy(oname, argv[++i]);
  111.                    break;
  112.             default  : haltusage();
  113.           }
  114.           break;
  115.       default : haltusage();
  116.       }
  117.     }
  118.   }
  119.  
  120.   if (strcmp(fname,""))
  121.     infile = fopen(fname, "rt");
  122.   else
  123.     infile = stdin;
  124.  
  125.   if (!infile)
  126.     {
  127.     fprintf(stderr, "hits: %s: couldn't open file\n", fname);
  128.     exit(0);
  129.     }
  130.  
  131.   if (strcmp(oname, ""))
  132.     outfile = fopen(oname, "wt");
  133.   else
  134.     outfile = stdout;
  135.  
  136.   if (!outfile)
  137.     {
  138.     fprintf(stderr, "hits: %s: could't create file\n", oname);
  139.     exit(0);
  140.     }
  141.  
  142.   createhitlist(infile, outfile);
  143.  
  144.   fclose(infile);
  145.   fclose(outfile);
  146.  
  147.   }
  148.  
  149. /* EOF HITS.C */
  150.  
  151.